import Toast from '@vant/weapp/toast/toast';

const server = "http://localhost";

/**
 * cgf
 * {
      url: '/api/goodslist',
      success:r=>{
        console.log(r);
        this.setData({
          arr:r.data.list
        })
      }
    }
 */
module.exports.server = server;
module.exports.request = cfg=>{
  return new Promise((resolve,reject)=>{
    cfg.url = server+cfg.url;
    cfg.success=r=>{
      if(r.data.code==0){
        //返回核心数据
        resolve(r.data);
      }else{
        Toast.fail(r.data.msg);
        reject();
      }
      console.log(r);
    }
    wx.request(cfg)
  })
 
}